<?php

function DealsBuildAdminMenuHook($backend)
{
	$backend->addMenuItem(ADMIN_SETTINGS, __('Deals Settings'),'/deals/deal_config/setting/Deal');
	if(cr('DealConfig.enable_deals')) 
	{
		$backend->addMenuItem(ADMIN_CONTENT, __('Deals'),'/deals/deals/index');
	}
}

function DealsAfterComponentInitHook($ctrl)
{
	App::import("Vendor","Deals.DealsUtility");
	DealsUtility::initializeConfiguration();
}

function DealsBeforeShellDispatchHook($ctrl)
{
	App::import("Vendor","Deals.DealsUtility");
	DealsUtility::initializeConfiguration();
}

function DealsGetSiteMapPagesHook(SiteMap $SiteMapModel)
{
	if(!checkSessionKeyForDeals())
	{
		return;
	}
	
	$dealIndexPages = new GigaAction(
			"dealIndex",
			__('Deals Index'),
			array("plugin"=>"deals","controller"=>"deals","action"=>"index")
	);
	$dealPages = new GigaAction(
			"dealView",
			__('Deal Pages'),
			array("plugin"=>"deals","controller"=>"deals","action"=>"view")
	);
	$pages = array($dealIndexPages,$dealPages);
	$SiteMapModel->pages = am($SiteMapModel->pages,$pages);
}

function DealsShellTasksHook($shell)
{
	$shell->tasks[] = "DealManage";
}

function DealsGetNewsletterTypesHook($model)
{
	if(isset($model->newsletterTypes))
	{
		$model->newsletterTypes[] = array(
			"type"        => "deal",
			"label"       => __("Deal newsletter"),
			"contentCall" => "Deals.DealNewsletterHandler"
		);
	}
}
?>